import json
import requests


class VodGetPlaySafeTokenRequest:
    def __init__(self):
        self.video_id = None
        self.viewer_id = None
        self.viewer_ip = None
        self.viewer_name = None
        self.expires = None
        self.disposable = None
        self.is_wxa = None

    def set_video_id(self, video_id):
        self.video_id = video_id
        return self

    def set_viewer_id(self, viewer_id):
        self.viewer_id = viewer_id
        return self

    def set_viewer_ip(self, viewer_ip):
        self.viewer_ip = viewer_ip
        return self

    def set_viewer_name(self, viewer_name):
        self.viewer_name = viewer_name
        return self

    def set_expires(self, expires):
        self.expires = expires
        return self

    def set_disposable(self, disposable):
        self.disposable = disposable
        return self

    def set_is_wxa(self, is_wxa):
        self.is_wxa = is_wxa
        return self


class VodGetPlaySafeTokenResponse:
    pass


class VodPlayerSettingsServiceImpl:
    def get_play_safe_token(self, request):
        # Implement your logic to make the API request and handle the response
        # For demonstration purposes, a placeholder response is used here
        response_data = {"token": "example_token"}
        response = VodGetPlaySafeTokenResponse()
        response.__dict__ = response_data
        return response


# Test code
def test_get_play_safe_token():
    vod_get_play_safe_token_request = VodGetPlaySafeTokenRequest()
    try:
        vod_get_play_safe_token_request.set_video_id("1b448be323b68b2999802799a98dba54_1") \
            .set_viewer_id("testViewerId") \
            .set_viewer_ip("example_viewer_ip") \
            .set_viewer_name("TestViewName") \
            .set_expires(60) \
            .set_disposable(True) \
            .set_is_wxa(0)

        vod_get_play_safe_token_response = VodPlayerSettingsServiceImpl().get_play_safe_token(
            vod_get_play_safe_token_request)

        assert vod_get_play_safe_token_response is not None
        if vod_get_play_safe_token_response:
            print(f"Successfully retrieved Playsafe Token: {json.dumps(vod_get_play_safe_token_response.__dict__)}")

    except Exception as e:
        # Handle exceptions
        print(f"Error: {str(e)}")


# Run the test
test_get_play_safe_token()